package com.etxxy.web.manager.impl;

import java.util.Map;

import javax.mail.MessagingException;

import org.springframework.beans.factory.annotation.Autowired;

import com.etxxy.remoting.dto.MailRequestDTO;
import com.etxxy.remoting.dto.SmsRequestDTO;
import com.etxxy.remoting.service.MailSenderService;
import com.etxxy.remoting.service.SmsSenderService;
import com.etxxy.web.manager.SmsEmailManager;

/**
 * TODO: 增加描述
 * 
 * @author yiz
 * @date 2016年5月16日 下午2:10:07
 * @version 1.0.0 
 * @copyright pycredit.cn 
 */
public class SmsEmailManagerImpl implements SmsEmailManager {

	@Autowired
	private MailSenderService mailSenderService;

	@Autowired
	private SmsSenderService smsSenderService;

	@Override
	public boolean sendMsg(String mobile, String templateContent, Map<String, Object> params) {
		SmsRequestDTO smsRequestDTO = new SmsRequestDTO();
		smsRequestDTO.setCheckType("1");
		smsRequestDTO.setMobile(mobile);
		smsRequestDTO.setTemplate(templateContent);
		smsRequestDTO.setData(params);
		smsSenderService.sendSms(smsRequestDTO);
		return false;
	}

	@Override
	public boolean sendEmail(String[] toEmails, String subject, String templateContent, Map<String, Object> params)
			throws MessagingException {
		MailRequestDTO mailRequestDTO = new MailRequestDTO();
		mailRequestDTO.setToEmails(toEmails);
		mailRequestDTO.setSubject(subject);
		mailRequestDTO.setTemplate(templateContent);
		mailRequestDTO.setData(params);
		boolean result = mailSenderService.sendMail(mailRequestDTO);
		return result;
	}

}
